package com.example.demo.generator.scaffold.registry;

import com.example.demo.generator.scaffold.model.TemplateContext;
import com.example.demo.generator.scaffold.model.TemplateDescriptor;
import com.example.demo.generator.scaffold.util.ScaffoldNameUtils;

import java.util.List;

public final class SolidityTemplates {

    private SolidityTemplates() {
    }

    public static List<TemplateDescriptor> all() {
        return List.of(contractTemplate());
    }

    private static TemplateDescriptor contractTemplate() {
        return TemplateDescriptor.builder()
                .id("solidity-contract")
                .templatePath("scaffold/templates/blockchain/solidity/Contract.sol.ftl")
                .outputPathResolver(SolidityTemplates::resolveContractPath)
                .build();
    }

    private static String resolveContractPath(TemplateContext context) {
        return ScaffoldNameUtils.deriveArtifactId(context) + "/src/main/resources/solidity/" + context.getClassInfo().getClassName() + ".sol";
    }
}
